// eee.Sheffield.PZ.Imaging
//
// Copyright ?Ping Zou, 2007
// sg71.cherub@gmail.com

using System;
using System.Collections.Generic;
using System.Text;
using eee.Sheffield.PZ.Math;
using System.Drawing;
using System.Drawing.Imaging;


namespace eee.Sheffield.PZ.Imaging.ImageFilter
{
    public enum ColourChannelEnum {R, G, B}

    /// <summary>
    /// return a colour channel
    /// </summary>
    public class ColourChannel : ImageFilter//, IColourImageFilter
    {
        
        #region Fields
        private ColourChannelEnum _colourChannelEnum;
        #endregion

        #region Constructor
        public ColourChannel()
        {
            _colourChannelEnum = ColourChannelEnum.R;
            _flag = "[Image -> Colour -> Colour Channel]";
            _normalize = false;
        }

        public ColourChannel(ColourChannelEnum colourChannel)
        {
            _colourChannelEnum = colourChannel;
            _flag = "[Image -> Colour -> Colour Channel]";
            _normalize = false;
        }
        #endregion

        #region Apply filter     

        protected override PZMath_matrix ApplyDoubleGraylevelImageFilter(PZMath_matrix srcMatrix, out string logText)
        {
            throw new Exception("The method or operation is not implemented.");
        } // ApplyDoubleGraylevelImageFilter()

        protected override PZMath_matrix[] ApplyDoubleColourImageFilter(PZMath_matrix[] srcMatrixArray, out string logText)
        {
            PZMath_matrix[] dstMatrixArray = new PZMath_matrix[3];

            switch (_colourChannelEnum)
            {
                case ColourChannelEnum.R:
                    dstMatrixArray[0] = new PZMath_matrix(srcMatrixArray[0]);
                    dstMatrixArray[1] = new PZMath_matrix(srcMatrixArray[0]);
                    dstMatrixArray[2] = new PZMath_matrix(srcMatrixArray[0]);
                    break;
                case ColourChannelEnum.G:
                    dstMatrixArray[0] = new PZMath_matrix(srcMatrixArray[1]);
                    dstMatrixArray[1] = new PZMath_matrix(srcMatrixArray[1]);
                    dstMatrixArray[2] = new PZMath_matrix(srcMatrixArray[1]);
                    break;
                case ColourChannelEnum.B:
                    dstMatrixArray[0] = new PZMath_matrix(srcMatrixArray[2]);
                    dstMatrixArray[1] = new PZMath_matrix(srcMatrixArray[2]);
                    dstMatrixArray[2] = new PZMath_matrix(srcMatrixArray[2]);
                    break;
            }
            logText = "success";
            return dstMatrixArray;
        } // ApplyDoubleColourImageFilter()
        #endregion


    }
}
